package findClosestNumber;

public class Solution {
    public int findClosestNumber(int[] nums) {
        int ans = Integer.MIN_VALUE;
        int minDis = Integer.MAX_VALUE;
        for (int num: nums) {
            int dis = Math.abs(num-0);
            if(dis<minDis) {
                minDis = dis;
                ans = num;
            }else if(dis == minDis) {
                ans = Math.max(ans,num);
            }
        }
        return ans;
    }
}
